package cn.stylefeng.guns.generator.engine.config;

import cn.stylefeng.guns.generator.executor.config.GunsGeneratorConfig;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class ServiceConfig {

    private String servicePathTemplate;
    private String serviceImplPathTemplate;

    private String packageName;

    private List<String> serviceInterfaceImports;
    private List<String> serviceImplImports;

    public ServiceConfig(GunsGeneratorConfig gunsGeneratorConfig) {
        ContextConfig contextConfig = gunsGeneratorConfig.getContextConfig();
        ArrayList<String> imports = new ArrayList<>();
        imports.add("org.springframework.stereotype.Service");
        imports.add("com.baomidou.mybatisplus.extension.service.impl.ServiceImpl");
        imports.add(contextConfig.getModelPackageName() + "." + contextConfig.getEntityName());
        imports.add(contextConfig.getModelMapperPackageName() + "." + contextConfig.getEntityName() + "Mapper");
        this.serviceImplImports = imports;

        ArrayList<String> interfaceImports = new ArrayList<>();
        interfaceImports.add("com.baomidou.mybatisplus.extension.service.IService");
        interfaceImports.add(contextConfig.getModelPackageName() + "." + contextConfig.getEntityName());
        this.serviceInterfaceImports = interfaceImports;

        this.servicePathTemplate = "/src/main/java/" + contextConfig.getProPackage().replaceAll("\\.", "/") + "/modular/" + contextConfig.getModuleName() + "/service/I{}Service.java";
        this.serviceImplPathTemplate = "/src/main/java/" + contextConfig.getProPackage().replaceAll("\\.", "/") + "/modular/" + contextConfig.getModuleName() + "/service/impl/{}ServiceImpl.java";
        this.packageName = contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".service";
    }

}
